﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using NETL.Engine.Util;
using NETL.Engine.Context;

namespace NETL.Engine.Transformation
{
	public class TransformationFactory : ITransformationFactory
	{
		public static ITransformationFactory Instance()
		{
			return new TransformationFactory();
		}

		#region ITransformationFactory Members

		public ITransformation BuildTransformation(NETL.Data.Config.TransformationData data)
		{
			ITransformation t = ClassFactory.Instance().BuildClass(data.Class) as ITransformation;
			t.Name = data.Name;
			foreach (XElement e in data.Data.Elements())
			{
				ReflectionUtil.SetProperty(t, e);
			}
			return t;
		}

		#endregion
	}
}
